﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CloudReader.IO.UserInfo
{
    public class UserManager
    {
        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf;
        public UserManager()
        {
            bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
        }
        public UserRelatives Load(string File)
        {
            if (System.IO.File.Exists(File))
            {
                var s = System.IO.File.OpenRead(File);
                return (UserRelatives)bf.Deserialize(s);
            }
            else
            {
                return null;
            }
        }
        public void Save(UserRelatives ur,string file)
        {
            try
            {
                var s = System.IO.File.Create(file);
                bf.Serialize(s, ur);
            }
            catch
            {

            }
        }
    }
}
